package com.qiniu;

import com.qiniu.api.auth.AuthException;
import com.qiniu.api.auth.digest.Mac;
import com.qiniu.api.config.Config;
import com.qiniu.api.rs.PutPolicy;
import org.json.JSONException;

public class Uptoken {

    public static void main(String[] args) throws Exception {
        String uptoken =getUpToken();
        System.out.println(uptoken);
    }

    public static String getUpToken() throws AuthException, JSONException {
        Config.ACCESS_KEY = QiNiuCofig.ACCESS_KEY;
        Config.SECRET_KEY = QiNiuCofig.SECRET_KEY;
        Mac mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
        // 请确保该bucket已经存在
        String bucketName = QiNiuCofig.BUCKTNAME;
        PutPolicy putPolicy = new PutPolicy(bucketName);
        return putPolicy.token(mac);
    }


}